package itheima.itheima_246;
/*
    自然排序
    存储学生对象并遍历，创建集合使用无参构造方法
    要求：按照年龄从小到大排序，年龄相同时，按照姓名的字母排序排序
 */
import java.util.TreeSet;

public class TreeSetDemo01 {
    public static void main(String[] args) {
        TreeSet<Student> ts = new TreeSet<Student>();

        Student s1 = new Student("xishi", 29);
        Student s2 = new Student("diaochan", 28);
        Student s3 = new Student("wangzhaojun", 30);
        Student s4 = new Student("yangyuhuan", 33);

        Student s5=new Student("linqingxia",33);
        Student s6=new Student("lingqingxia",33);

        ts.add(s1);
        ts.add(s2);
        ts.add(s3);
        ts.add(s4);

       for (Student s:ts){
           System.out.println(s.getName()+","+s.getAge());
       }
    }
}
